/* Vote 板块下的 reducer */
import _ from "@/assets/utils"
import * as TYPES from "../action-types"

const initial = {
    supNum: 10,
    oppNum: 5,
    num: 0
}

export const voteReducer = function (state = initial, action) {
    state = _.clone(true, state)
    let {type, payload} = action
    switch (type) {
        case TYPES.VOTE_SUP:
            state.supNum++
            break
        case TYPES.VOTE_OPP:
            state.oppNum++
            break
    }
    return state
}

/*
* 不需要自己单独写字符串值勒
* 而是把 action-types 中统一管理的标识拿来进行判断
* 特点：写的时候还有提示呢，不容易出错！！
*
* 统一管理派发的行为标识，除了保证不冲突，还能避免程序员因为粗心大意，导致的错误
*
*
* */